package com.lihan.GetSeatInLib.Domain;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.springframework.format.annotation.DateTimeFormat;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.lihan.GetSeatInLib.Domain.Enums.OrderStatus;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

@ApiModel("定位操作Model")
@Entity
@Table(name = "t_orders")
@JsonIgnoreProperties(value = {"hibernateLazyInitializer"})
public class Order {
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@ApiModelProperty("主键ID")
	@Column(name = "order_id")
	private long ID;
	
	@ManyToOne(cascade = CascadeType.PERSIST) //设置级联等级 PERSIST对应Hibernate的SaveAndUpdate
	@JoinColumn(name = "order_owner")
	@ApiModelProperty("预定动作所对应的用户（多对一的关联）")
	private User owner;
	
	@ManyToOne(cascade = CascadeType.PERSIST)
	@JoinColumn(name = "order_seat")
	@ApiModelProperty("预定动作所对应的桌子（多对一的关联）")
	private SeatModel seat;
	
	@Column(name = "create_time")
	@ApiModelProperty("预定的创建时间")
	private Date creatTime;
	
	@Column(name = "quit_time")
	@ApiModelProperty("提前离开的时间")
	private Date QuitTime;
	
	@Column(name = "order_status")
	@ApiModelProperty("预定的状态")
	private OrderStatus status;
	
	@Column(name = "order_start")
	@JsonFormat(pattern = "YYYY/MM/DD hh:mm")
	@DateTimeFormat(pattern = "YYYY/MM/DD hh:mm")
	@ApiModelProperty("使用的开始时间")
	private Date StartTime;
	
	@Column(name = "order_end")
	@JsonFormat(pattern = "YYYY/MM/DD hh:mm")
	@DateTimeFormat(pattern = "YYYY/MM/DD hh:mm")
	@ApiModelProperty("使用的结束时间")
	private Date EndTime;

	
	
	
	public Order(long iD, User owner, SeatModel seat, Date creatTime, OrderStatus status, Date startTime,
			Date endTime) {
		
		ID = iD;
		this.owner = owner;
		this.seat = seat;
		this.creatTime = creatTime;
		this.status = status;
		StartTime = startTime;
		EndTime = endTime;
	}

	public Order() {
		
	}

	public long getID() {
		return ID;
	}

	public void setID(long iD) {
		ID = iD;
	}

	public User getOwner() {
		return owner;
	}

	public void setOwner(User owner) {
		this.owner = owner;
	}

	public SeatModel getSeat() {
		return seat;
	}

	public void setSeat(SeatModel seat) {
		this.seat = seat;
	}

	public Date getCreatTime() {
		return creatTime;
	}

	public void setCreatTime(Date creatTime) {
		this.creatTime = creatTime;
	}

	public OrderStatus getStatus() {
		return status;
	}

	public void setStatus(OrderStatus status) {
		this.status = status;
	}

	public Date getStartTime() {
		return StartTime;
	}

	public void setStartTime(Date startTime) {
		StartTime = startTime;
	}

	public Date getEndTime() {
		return EndTime;
	}

	public void setEndTime(Date endTime) {
		EndTime = endTime;
	}

	public Date getQuitTime() {
		return QuitTime;
	}

	public void setQuitTime(Date quitTime) {
		QuitTime = quitTime;
	}
	
	

}
